package mrusanov.ai

import mrusanov.battle.Battle
import mrusanov.team.Team

class StupidBattleAI extends BattleAI {
  def makeTurn(battle:Battle, team:Team) {
    if (battle.canBeTurnOver(team)) {
      return
    }

    while (!battle.canBeTurnOver(team)) {
      val wonArena = battle.miniArenas find (ma => ma.getPlayer(team).isDefined && ma.isOver)
      assert(wonArena.isDefined)
      val emptyArena = battle.miniArenas find (ma => ma.getPlayer(team).isEmpty && !ma.isOver)
      assert(emptyArena.isDefined)

      battle.moveVictoriousPlayerToNewArena(wonArena.get.getPlayer(team).get, emptyArena.get)
    }
  }
}
